package com.ny.zmb.openapi.controller;

import com.alibaba.fastjson.JSONObject;
import com.ny.zmb.openapi.controller.entity.Result;
import com.ny.zmb.openapi.entity.PmCloudstore;
import com.ny.zmb.openapi.mapper.PmCloudStoreMapper;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/pmCloudStore")
@Api(tags = "分类", description = "分类")
public class PmCloudStoreController {
    @Resource
    private PmCloudStoreMapper pmCloudStoreMapper;

    @GetMapping("/getPidS")
    public Result getPidS(Integer id) {
        List<Integer> ids = new ArrayList<>();
        PmCloudstore pmCloudStore = pmCloudStoreMapper.selectById(id);
        ids.add(id);
        while (pmCloudStore != null) {
            if (pmCloudStore.getPid() == 0){
                return Result.ok(ids);
            }
            ids.add(0,pmCloudStore.getPid());
            pmCloudStore = pmCloudStoreMapper.selectById(pmCloudStore.getPid());
        }
        return Result.ok(ids);
    }

}
